<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>

  <div class="box">
    <h1>{{data}}</h1>
    <button @click="fn">按钮</button>
  </div>



  <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
  <script>
    // 3. 创建Vue实例
    const app = new Vue({
      el: '.box',
      data: {
        data: 'HELLO,WORLD'
      },
      methods: {
        fn() {
          /* let arr = ''
          for (let i = this.data.length - 1; i >= 0; i--) {
            arr += this.data[i]
          }
          this.data = arr */


          this.data = this.data.split('').reverse().join('')
        }
      }
    })
  </script>
</body>

</html>